# 7-8 各位数字之和为5的数【字符串】
def AllSum():
    def digit_sum(num):
        return sum(int(digit) for digit in str(num))

    n = int(input())
    result = [str(num) for num in range(n + 1) if digit_sum(num) == 5]
    print(" ".join(result))
AllSum()